package com.ry.project.login.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.LockedAccountException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.ry.common.utils.JedisUtils;
import com.ry.framework.redis.JedisConfig;

import redis.clients.jedis.Jedis;

@Controller
public class IndexController {

	@Autowired
	private JedisUtils jedisUtils;
	
	@RequiresRoles("admin")
	@RequestMapping("/admin")
	@ResponseBody
	public String index() {
		System.out.println("**************访问首页*************");
		Subject subject = SecurityUtils.getSubject();
		System.out.println(subject.isPermitted("add"));
		
		Jedis jedis = jedisUtils.getResource();
		String str = jedis.get("test");
		jedis.close();
		System.out.println("测测测：" + str);
		
		return "admin";
	}
	
	
}
